<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>滇宏教育-添加教师</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <blockquote class="layui-elem-quote layui-text">
            Nothing is ok
        </blockquote>

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>添加教师</legend>
        </fieldset>

        <form class="layui-form" action="/manager2/user/teacher/listTeacher">
            <div class="layui-form-item">
                <label class="layui-form-label">教师姓名</label>
                <div class="layui-input-block">
                    <input type="hidden" name="tid" lay-verify="title" autocomplete="off" placeholder="请输入用户名" class="layui-input" value="null">
                    <input type="text" name="tname" lay-verify="title" autocomplete="off" placeholder="请输入用户名" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">毕业院校</label>
                <div class="layui-input-block">
                    <input type="text" name="college" lay-verify="title" autocomplete="off" placeholder="毕业院校" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block">
                    <input type="radio" name="tgender" value="男" title="男">
                    <input type="radio" name="tgender" value="女" title="女">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">联系电话</label>
                    <div class="layui-input-inline">
                        <input type="tel" name="tel" lay-verify="required|phone" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">用户身份</label>
                <div class="layui-input-block">:
                    <input type="checkbox" name="type" title="超级管理员" value="7">
                    <input type="checkbox" name="type" title="语文老师" value="1">
                    <input type="checkbox" name="type" title="数学老师" value="2">
                    <input type="checkbox" name="type" title="英语老师" value="3">
                    <input type="checkbox" name="type" title="化学老师" value="4">
                    <input type="checkbox" name="type" title="物理老师" value="5">
                    <input type="checkbox" name="type" title="生物老师" value="6">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">住址</label>
                <div class="layui-input-block">
                    <input type="text" name="address" lay-verify="title" autocomplete="off" placeholder="住址" class="layui-input">
                </div>
            </div>


            <!--<div class="layui-form-item layui-form-text">
              <label class="layui-form-label">编辑器</label>
              <div class="layui-input-block">
                <textarea class="layui-textarea layui-hide" name="content" lay-verify="content" id="LAY_demo_editor"></textarea>
              </div>
            </div>-->
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>

        <!-- 示例-970 -->
        <ins class="adsbygoogle" style="display:inline-block;width:970px;height:90px" data-ad-client="ca-pub-6111334333458862" data-ad-slot="3820120620"></ins>





    </div>
</div>

<script src="../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../js/jquery-1.11.3.min.js"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1'
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            title: function (value) {
                if (value.length < 2) {
                    return '用户名至少得2个字符啊';
                }
            }
            , pass: [
                /^[\S]{6,12}$/
                , '密码必须6到12位，且不能出现空格'
            ]
            , content: function (value) {
                layedit.sync(editIndex);
            }
        });

        //监听指定开关
        form.on('switch(switchTest)', function (data) {
            layer.msg('开关checked：' + (this.checked ? 'true' : 'false'), {
                offset: '6px'
            });
            layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
        });

        //监听提交
        form.on('submit(demo1)', function (data) {


            var industryObj = $('input[name="type"]');
            var check_val = [];
            for(k in industryObj){
                if(industryObj[k].checked){
                    check_val.push(industryObj[k].value);
                }
            }

            data.field.type = check_val;


            var teacher = JSON.stringify(data.field);
            /*layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            })
*/

            $.ajax({
                url:'../../teacher/add',
                data:{teacher1:teacher},
                success:function (msg) {
                    layer.alert(msg, {
                        title: '信息'
                    });
                },
                error:function () {
                    layer.alert('failed');
                }

            })

            return false;
        });




    });
</script>

</body>
</html>